# define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int m, n;
    int a[6][6];
    scanf("%d %d\n", &m, &n);
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
            scanf("%d ", &a[i][j]);
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (j != 0)
                printf(" ");
            printf("%d", a[j][i]);
        }
        printf("\n");
    }
    return 0;
}